import pageination from '../../components/pageination/pageination.vue'
export default {
	data() {
		return {
			//数据
      allStudent: [],
			total: 0, //总条数
			page: 1, //当前页
			size: 10,//每页显示条数
		}
	},
	components: {
		pageination
	},
	created() { //调用方法
	},
	mounted() {
	},
	methods: { //写函数方法
	  // 批量通过
    checkStu: function () {
      let that = this;
      $('input[name="checkedStudent"]:checked').each(function(){
        that.through($(this).attr('data-id'), $(this).attr('data-identityCard'), $(this).attr('data-name')  ,
          $(this).attr('data-phone'), $(this).attr('data-industry')
          , $(this).attr('data-reserved')
          , $(this).attr('data-reserved2')

        );

        setTimeout(function () {

        }, 100);

      });

    },
    // 单个通过
    through: function (id, identityCard, name, phone, industry,reserved , reserved2) {
      let that = this;
      // 提交
      that.$post(
        that.urls.studentDetermine,
        {"id": id, "identityCard": identityCard, "name": name, "phone": phone, "industry": industry
            ,"reserved":reserved, "reserved2": reserved2
        }
      )
        .then(function(res) {
          if(res.success) {
            that.modelShowStudents = false;
            layer.msg(res.message, {
              time: 3000, //3s后自动关闭
            });
            that.searchSudent();
            that.sendMsg(phone,identityCard);
          }
        })
    },

    // 搜索学生列表
    searchSudent: function () {
      let that = this;
      let value = $('#searchSudentVal').val();
      // 所有学生学生
      that.$post(
        that.urls.findAllStudent, //    审核状态(0：待审核；1：审核通过；2：审核不通过)
        {"pageNum": that.page,"pageSize": that.size, "identityCard": value,  auditStatus: 0}
      )
        .then(function(res) {
          if(res.success) {
            that.allStudent = res.pageInfo.list;
            that.total = res.pageInfo.total;
            that.page = res.pageInfo.pageNum;

          }
        })
    },
		//页码切换执行方法
		pageFn: function(val, pid) {
			this.page = parseInt(val);
			//此处调列表数据接口
      this.searchSudent();
	//		this.searchTodo(pid); //查询新闻
		},
		/**返回子组件用户选择的一页显示条数**/
		obtainChild: function(data) {
			this.row = data;
		},

    sendMsg: function (phone,identityCard) {
       let that = this;
       let content = '您申请的账号已经通过注册了，账号为:'+ identityCard + '密码为:'+identityCard.substr(identityCard.length-6, identityCard.length);

      console.log(phone)
        console.log(content)
      that.$post(
        that.urls.sendMsg,
        {"receiver": phone, "smscontent": content}
      )
        .then(function(res) {
          if(res.success) {

          }
        })

    }

	}
}
